<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="${ctx }/resources/lib/html5.js"></script>
<script type="text/javascript" src="${ctx }/resources/lib/respond.min.js"></script>
<script type="text/javascript" src="${ctx }/resources/lib/PIE_IE678.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="${ctx }/resources/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="${ctx }/resources/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="${ctx }/resources/lib/Hui-iconfont/1.0.7/iconfont.css" />
<link rel="stylesheet" type="text/css" href="${ctx }/resources/lib/icheck/icheck.css" />
<link rel="stylesheet" type="text/css" href="${ctx }/resources/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="${ctx }/resources/css/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="${ctx }/resources/lib/dtGrid-v1.1.9/jquery.dtGrid.css" />
<title>用户列表</title>
</head>
<body>
<div class="page-container">
	<form class="form form-horizontal" id="form-add" method="post" action="${ctx }/account/save">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span> 登陆邮箱：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="hidden" class="input-text" value="${account.accountId }" id="accountId" name="accountId">
				<input type="text" class="input-text" value="${account.accountName }" placeholder="登陆使用的邮箱" id="accountName" name="accountName">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"> 真实姓名：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="${account.accountRealName }" placeholder="用户真实姓名" id="accountRealName" name="accountRealName">
			</div>
		</div>
		<div class="row cl" id="passwordDiv">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span> 登陆密码：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="password" class="input-text" value="${account.password }" placeholder="登录使用的密码" id="password" name="password">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"> 是否锁定：</label>
			<div class="formControls col-xs-8 col-sm-9 skin-minimal">
				<div class="check-box">
					<c:choose>
						<c:when test="${account.lockFlag == 1}">
							<input type="checkbox" id="checkbox-1" name="lockFlag" value="1" checked="checked">
						</c:when>
						<c:otherwise>
							<input type="checkbox" id="checkbox-1" name="lockFlag" value="0">
						</c:otherwise>
					</c:choose>
					<label for="checkbox-1">&nbsp;</label>
				</div>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">用户角色：</label>
			<div class="formControls col-xs-8 col-sm-9 skin-minimal">
				<dl class="permission-list">
					<dd>
						<dl class="cl permission-list2">
							<c:forEach items="${roleList }" var="role">
								<label class="">
									<input type="checkbox" value="${role.roleId }" name="roles" id="role" <c:if test="${role.checked eq true }">checked</c:if>> ${role.roleName }
								</label>
							</c:forEach>
						</dl>
					</dd>
				</dl>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"> 用户描述：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<textarea name="description" cols="" rows="" class="textarea"  placeholder="说点什么...最少输入10个字符" datatype="*10-100" dragonfly="true" nullmsg="备注不能为空！" onKeyUp="textarealength(this,200)">${account.description }</textarea>
				<p class="textarea-numberbar"><em class="textarea-length">0</em>/200</p>
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
				<button class="btn btn-secondary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存</button>
				<button onClick="layer_close();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
			</div>
		</div>
	</form>
</div>
<script type="text/javascript" src="${ctx }/resources/lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="${ctx }/resources/lib/bootstrap/bootstrap.min.js"></script>
<script type="text/javascript" src="${ctx }/resources/lib/layer/2.1/layer.js"></script> 
<script type="text/javascript" src="${ctx }/resources/lib/My97DatePicker/WdatePicker.js"></script> 
<script type="text/javascript" src="${ctx }/resources/js/H-ui.js"></script> 
<script type="text/javascript" src="${ctx }/resources/js/H-ui.admin.js"></script> 
<script type="text/javascript" src="${ctx }/resources/lib/dtGrid-v1.1.9/jquery.dtGrid.js"></script>
<script type="text/javascript" src="${ctx }/resources/lib/dtGrid-v1.1.9/i18n/zh-cn.js"></script>
<script type="text/javascript" src="${ctx }/resources/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="${ctx }/resources/ams/util/util.js"></script>
<script type="text/javascript">
$(function(){
	if('edit' === '${operation}'){
		$('#passwordDiv').hide();
	} else if ('add' === '${operation}'){
		$('#passwordDiv').show();
	} else {
		$('#passwordDiv').show();
	}
	
	$("#form-add").validate({
		rules:{
			accountName:{
				required:true,
				email:true
			},
			password:{
				required:true
			},
			role:{
				required:true
			}
		},
		messages:{
			accountName:{
                required:"必填",
                email:'E-Mail格式不正确'
            },
            password:{
                required:"必填"
            },
            role:{
                required: "不能为空"
            }                                    
        },
        submitHandler:function(form){
        	$.ajax({  
        	    url : '${ctx}/account/save',
        	    data : $("#form-add").serialize(),  
        	    type:'post',  
        	    cache:false,  
        	    dataType:'json',  
        	    success:function(data) {  
        	        if(data){  
        	        	var index = parent.layer.getFrameIndex(window.name);
        				parent.searchRows();
        				parent.layer.close(index);
        	        }else{  
        	        	layer.msg('数据保存失败，请稍后重新尝试!',{icon: 5,time:1000});
        	        }  
				},  
				error : function() { 
					layer.msg('服务器异常，请联系管理员!',{icon: 5,time:1000});
				}  
        	});
			
        }  
	});
});

</script>
</body>
</html>